trilhas_saltinho_proposta

Pacotes

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(sf)
Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
library(readxl)

library(parzer)

library(raster)
Carregando pacotes exigidos: sp

Anexando pacote: 'raster'

O seguinte objeto é mascarado por 'package:dplyr':

    select
library(terra)
terra 1.7.71

Anexando pacote: 'terra'

O seguinte objeto é mascarado por 'package:tidyr':

    extract
library(tidyterra)

Anexando pacote: 'tidyterra'

O seguinte objeto é mascarado por 'package:raster':

    select

O seguinte objeto é mascarado por 'package:stats':

    filter

Dados

Raster

saltinho_raster <- terra::rast("saltinho.tif")

ggplot() +
  tidyterra::geom_spatraster_rgb(data = saltinho_raster) +
  scale_x_continuous(expand = c(0, 0)) +
  scale_y_continuous(expand = c(0, 0))
<SpatRaster> resampled to 500992 cells.

Shapefiles

Saltinho

saltinho_poligono <- sf::st_read("Saltinho.shp")
Reading layer `Saltinho' from data source 
  `G:\Meu Drive\UFPE\projeto mestrado\mestrado\Saltinho.shp' 
  using driver `ESRI Shapefile'
Simple feature collection with 1 feature and 14 fields
Geometry type: POLYGON
Dimension:     XY
Bounding box:  xmin: -35.19784 ymin: -8.739185 xmax: -35.16593 ymax: -8.712074
Geodetic CRS:  SIRGAS 2000
saltinho_poligono %>% 
  ggplot() +
  geom_sf()

Grade 500m x 500m

nova_ext <- saltinho_raster %>% 
  terra::ext() %>% 
  terra::as.polygons(crs = saltinho_poligono %>% terra::crs()) %>% 
  sf::st_as_sf()

grade <- sf::st_read("modelo_grade_saltinho.shp") %>% 
  sf::st_transform(crs = saltinho_poligono %>% sf::st_crs()) %>% 
  sf::st_intersection(nova_ext)
Reading layer `modelo_grade_saltinho' from data source 
  `G:\Meu Drive\UFPE\projeto mestrado\mestrado\modelo_grade_saltinho.shp' 
  using driver `ESRI Shapefile'
Simple feature collection with 24 features and 5 fields
Geometry type: LINESTRING
Dimension:     XY
Bounding box:  xmin: -35.21912 ymin: -8.743586 xmax: -35.15781 ymax: -8.698458
Geodetic CRS:  WGS 84
Warning: attribute variables are assumed to be spatially constant throughout
all geometries
grade %>% 
  ggplot() +
  geom_sf()

Trilhas Horizontais

trilhas <- sf::st_read("trilhas horizontais.shp") %>% 
  sf::st_make_valid()
Reading layer `trilhas horizontais' from data source 
  `G:\Meu Drive\UFPE\projeto mestrado\mestrado\trilhas horizontais.shp' 
  using driver `ESRI Shapefile'
Simple feature collection with 7 features and 11 fields
Geometry type: LINESTRING
Dimension:     XYZ
Bounding box:  xmin: -35.19159 ymin: -8.734947 xmax: -35.16912 ymax: -8.716717
z_range:       zmin: 0 zmax: 0
Geodetic CRS:  WGS 84
trilhas %>% 
  ggplot() +
  geom_sf()

Coordenadas

coord <- readxl::read_xlsx("coordenadas_proposta.xlsx") %>% 
  dplyr::mutate(Longitude = Longitude %>% parzer::parse_lon(),
                Latitude = Latitude %>% parzer::parse_lat(),
                `Parcela Ripária` = dplyr::case_when(Trilha == "Ripária" ~ "Sim",
                                                     .default = "Não")) %>% 
  sf::st_as_sf(coords = c("Longitude", "Latitude"), crs = saltinho_poligono %>% sf::st_crs())

coord
coord %>% 
  ggplot() +
  geom_sf(aes(fill = `Parcela Ripária`), shape = 21, color = "black", size = 5)

Mapa

ggplot() +
  tidyterra::geom_spatraster_rgb(data = saltinho_raster) +
  geom_sf(data = saltinho_poligono, fill = "transparent", color = "red", linewidth = 2) +
  geom_sf(data = grade, color = "yellow") +
  geom_sf(data = trilhas, color = "blue", linewidth = 1.5) +
  geom_sf(data = coord, aes(fill = `Parcela Ripária`), size = 5, shape = 21, color = "black") +
  scale_y_continuous(expand = c(0, 0)) +
  scale_x_continuous(expand = c(0, 0)) +
  scale_fill_manual(values = c("gold", "cyan4")) +
  guides(fill = guide_legend(title.position = "top",
                             title.hjust = 0.5)) +
  theme_bw() +
  theme(axis.text = element_text(color = "black", size = 15),
        legend.text = element_text(color = "black", size = 15),
        legend.title = element_text(color = "black", size = 15),
        legend.position = "bottom")
<SpatRaster> resampled to 500992 cells.

ggsave("mapa_proposta_saltinho_parcelas.png", height = 10, width = 12)